package algotithm.acwing.prefixadd.test1230;

import java.io.*;

/**
 * @author zhouyanxiang
 * @Date 2021-02-2021/2/4-22:18
 * @Title 1230. K倍区间
 * @URL https://www.acwing.com/problem/content/1232/
 */
public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));
        String[] num = reader.readLine().split(" ");
        int n = Integer.parseInt(num[0]);
        int k = Integer.parseInt(num[1]);

        int[] cnt = new int[100005];
        int[] sum = new int[100005];
        long res = 0;
        for (int i = 1; i <= n; i++) {
            int x = Integer.parseInt(reader.readLine());
            sum[i] += (sum[i-1] + x) % k;
            res += cnt[sum[i] % k];
            cnt[sum[i] % k]++;
        }
        writer.write(res + cnt[0] + "\n");
        writer.flush();
        writer.close();
        reader.close();
    }

}
